var index_select
function selectData(obj) {
    reflush_index_select(obj)
    index_select=layer.open({
        content: $('#dictiValueList').html()
        ,area: ['500px', '400'] //自定义文本域宽高
        ,title:'xx新增'
        ,type:1
        ,btn: ['确定', '取消']
        ,yes: function(){
            submitEnter();
        }
        ,btn2: function(){
            //按钮【取消】的回调
            return 0;
        } //用于layui表单重新渲染
        ,success: function(layero){
            layui.use('form', function(){
                var form = layui.form;
                form.render();
            });
        }
    });
}
function reflush_index_select(obj) {
    var res={page:1,size:10,modelId:obj}
    var data=urldata('get','/dicti/dictiPage',res)
    data.modelId=obj
    laytemplatelist_1(data,'dictiValueList')

}

var num_3=0
var tplContent_list_1;
function laytemplatelist_1(obj,id) {
    var laytpl = layui.laytpl;
    var id=document.getElementById(id);
    if(num_3===0){
        tplContent_list_1=id.innerHTML;
        num_3++;
    }
    var tpl=tplContent_list_1;
    laytpl(tpl).render(obj, function(html){
        id.innerHTML = html;
    });
}


//字典值新增
var index_addDictiValue
function addDictiValue(obj) {
    var data={}
    data.id=obj
    laytemplateSave_dictivalue_1(data,'addDictiValue')
    index_addDictiValue=layer.open({
        content: $('#addDictiValue').html()
        ,area: ['500px', '400'] //自定义文本域宽高
        ,title:'xx新增'
        ,type:1
        ,btn: ['确定', '取消']
        ,yes: function(){
            submitEnterDictiValue();
        }
        ,btn2: function(){
            //按钮【取消】的回调
            return 0;
        } //用于layui表单重新渲染
        ,success: function(layero){
            layui.use('form', function(){
                var form = layui.form;
                form.render();
            });
        }
    });
}
//对应上面的
var num_4=0
var tplContent_save_dictivalue_1;
function laytemplateSave_dictivalue_1(obj,id) {
    var laytpl = layui.laytpl;
    var id=document.getElementById(id);
    if(num_4===0){
        tplContent_save_dictivalue_1=id.innerHTML;
        num_4++;
    }
    var tpl=tplContent_save_dictivalue_1;
    laytpl(tpl).render(obj, function(html){
        id.innerHTML = html;
    });
}
function submitEnterDictiValue() {
    var data= $("#add-dictivalue-form").serialize();
    data = decodeURIComponent(data,true);
    var data_json=DataDeal.formToJson(data);
    data_json=JSON.parse(data_json)
    var obj=urldata('get','/dicti/addDicti',data);
    if(obj.code==0){
        layer.msg("新增成功")
        //刷新表单
        layer.close(index_addDictiValue);
        layer.close(index_select);
        selectData(data_json.modelId)
    }else {
        layer.msg(obj.msg)
    }
}